import request from '@/common/request.js'
import {
	RegisterForm,
	UpdateInfoForm,
	LoginForm
} from "./type"
//用户登录
const login = (data) => {
	const url = '8181/auth/userLogin';
	return request.globalRequest(url, 'POST', data, 1)
}
//用户注册
const register = (data) => {
	const url = '8181/auth/userRegister';
	return request.globalRequest(url, 'POST', data, 1)
}

//用户信息修改
const updateInfo = (data) => {
	const url = '8181/auth/editUser';
	return request.globalRequest(url, 'POST', data, 1)
}

//用户查看个人信息
const getOwnInfo = (data) => {
	const url = '8181/auth/lookOwnInfo';
	return request.globalRequest(url, 'get', null, 1)
}

//获取所有用户信息
const getAllUserInfo = (data) => {
	const url = '8181/auth/getAllUserInfo';
	return request.globalRequest(url, 'post', data, 1)
}

//删除用户信息
const deleteUserInfo = (id) => {
	const url = `8181/auth/deleteUserInfo?id=${id}`;
	return request.globalRequest(url, 'delete', {}, 1)
};
//插入管理员信息
const insertAdminFun = (data) => {
	const url = '8181/auth/insertAdmin';
	return request.globalRequest(url, 'post', data, 1)
}

//插入学生信息
const insertStudentFun = (data) => {
	const url = '8181/student/insertStudent';
	return request.globalRequest(url, 'post', data, 1)
}
//修改密码
const changePassword = (data) => {
	const url = '8181/auth/change-password'
	return request.globalRequest(url, 'POST', data, 1)
}

//插入老师信息
const insertTeacherFun = (data) => {
	const url = '8181/teacher/insertTeacher';
	return request.globalRequest(url, 'post', data, 1)
}
export default {
	login,
	register,
	updateInfo,
	getOwnInfo,
	getAllUserInfo,
	deleteUserInfo,
	insertAdminFun,
	insertStudentFun,
	insertTeacherFun,
	changePassword
};